﻿using System;
using System.Text.RegularExpressions;
using Qadir.Collections.Generic;

namespace Qadir
{
    /// <summary>
    /// A handy set of functions that exist to make your life as a .NET programmer much easier!
    /// </summary>
    public class Qadir
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="objects"></param>
        public Qadir(Manager<object> objects)
        {

        }

        public static Manager<T> GetInstancesOf<T>()
        {
            return new Manager<T>();
        }

        public static Qadir Search(string query, bool caseSensitive = false)
        {
            Manager<string> selectors = new Manager<string>(query.Split(',')).ApplyActionToAllAndReceiveResults(s => s.Trim());
            return selectors.ApplyActionToAllAndReceiveResults<object>((selector) =>
                {                  

                    Regex rgxType = new Regex(@"^[a-zA-Z]+\s*$", RegexOptions.Multiline |  (caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase));
                    if (rgxType.IsMatch(selector))
                    {
                        Type type = Type.GetType(selector, true, !caseSensitive);
                        // Need to get all instances...
                        This is a deliberate error!
                    }

                    Regex rgxWithAttributes = new Regex("^[a-zA-Z]+\\s*\\[\\s*([a-zA-Z]+\\s*=\\s*\"[^\"]+\")(\\s*,\\s*[a-zA-Z]+\\s*=\\s*\"[^\"]+\")*\\s*\\]$", RegexOptions.Multiline | (caseSensitive ? RegexOptions.None : RegexOptions.IgnoreCase));
                    if (rgxWithAttributes.IsMatch(selector))
                    {

                    }

                });
        }
    }
}
